package com.msb.datastructure;

/**
 * @author dataexa
 * @Date 2023/12/8
 */
public class NodeTest {
    public static void main(String[] args) {
        Node node = new Node("1");
        Node node2 = new Node("2");
        Node node3 = new Node("3");
        Node node4 = new Node("4");
        Node node5 = new Node("5");
        Node node6 = new Node("6");
        node.next = node2;
        node2.next = node3;
        node3.next = node4;
        node4.next = node5;
        node5.next = node6;
        Node node1 = reverseNode(node);
        System.out.println();

    }

    private static Node reverseNode(Node head) {
        if (head == null || head.next == null) {
            return head;
        }
        Node node = reverseNode(head.next);
        head.next.next = head;
        head.next = null;
        return node;
    }

}

class Node {
    String name;
    Node next;

    public Node(String name) {
        this.name = name;
    }
}